/**
 * Project Name:九色鹿
 * File Name:CustomerUserDetails.java
 * Package Name:com.fxp.project.jiuselu.web.security.userdetails
 * Date:2021-08-29 12:38 下午
 * Copyright (c) 2021, Jason.Wang All Rights Reserved.
 */
package com.fxp.project.jiuselu.web.security.userdetails;

import com.fxp.project.jiuselu.web.models.user.entity.JslUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Arrays;
import java.util.Collection;

/**
 * ClassName: CustomerUserDetails<br/>
 * Function: 自定义的实体对象<br/>
 * Date: 2021-08-29 12:38 下午<br/>
 *
 * @author Jason.Wang
 * @version 1.0.0.0
 * @see
 * @since JDK 1.8
 */
@Data
public class CustomerUserDetails implements UserDetails {
    private JslUser jslUser;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        //返回当前用户的权限
        return Arrays.asList(new SimpleGrantedAuthority("USER"));
    }

    @Override
    public String getUsername() {
        return jslUser.getUserId().toString();
    }

    @Override
    public String getPassword() {
        return jslUser.getPassword();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
